package com.huibao.hulibao.applictaion;

import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.StrictMode;

import com.apkfuns.logutils.LogUtils;
import com.google.gson.Gson;
import com.huibao.hulibao.constant.GlobalConstants;
import com.huibao.hulibao.receiver.MyJPushReceiver;
import com.huibao.hulibao.utils.PreUtils;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;

import org.xutils.x;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by lizhaoyong on 2018/5/4.
 */
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        JPushInterface.init(this);
        x.Ext.init(this);
        // 开启日志输出
        x.Ext.setDebug(true);
        GlobalConstants.gson = new Gson();
        // 扫码
        ZXingLibrary.initDisplayOpinion(this);

        // 7.0拍照
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
//            StrictMode.setVmPolicy(builder.build());
//        }

        try {
            PackageManager packageManager = getPackageManager();
            // getPackageName()是你当前类的包名，0代表是获取版本信息
            PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(), 0);
            GlobalConstants.APP_VERSION = packInfo.versionName;
        } catch (Exception e) {
            e.printStackTrace();
        }


        GlobalConstants.URL = (String) PreUtils.getParam(getApplicationContext(), GlobalConstants.SP_URL, "");
        GlobalConstants.HOST = (String) PreUtils.getParam(getApplicationContext(), GlobalConstants.SP_HOST, "");

    }
}
